"use client"
import { Button } from "@heroui/button";
import { Form } from "@heroui/form";
import { Input } from "@heroui/input";
import React from "react";
import { useRouter } from 'next/navigation';
export default function MySub() {
    const router = useRouter()
    const onSubmit = (e: { preventDefault: () => void; currentTarget: HTMLFormElement | undefined; }) => {
        e.preventDefault();
        const data = Object.fromEntries(new FormData(e.currentTarget));
        const encodedPath = encodeURIComponent(`${data.title}`);
        router.push(`/search/${encodedPath}`)
    };

    return (
        <>
            <Form
                className="w-full max-w-xl flex flex-row gap-3"
                onSubmit={onSubmit}
            >
                <Input
                    labelPlacement="outside"
                    name="title"
                    placeholder="输入关键词（不用全名也可）"
                    className="border-2 border-blue-500"
                    radius="none"
                />
                <Button type="submit" color="primary" radius="none">
                    搜 索
                </Button>
            </Form>
        </>
    );
}


